package com.accedo.achievements.dataaccess.dao;

import java.util.List;

import com.accedo.achievements.dataaccess.model.User;

/**
 * A DAO interface with user model database operations.
 * @author Bo Liang
 */
public interface UserDao {
	
	/**
	 * Get user object by using user id.
	 * @param user_id	user id
	 * @return			user object
	 */
	public User getUserByUserId(int user_id);
	
	/**
	 * Get friends' id List by using user id.
	 * @param user_id	user id
	 * @return			List of friends' id
	 */
	public List<Integer> getFriendIdListByUserId(int user_id);
	
	/**
	 * Add achievement to user when user unlock this achievement.
	 * <p>user may unlocked this achievement before, if so, just add 1 to the number of unlocked of this achievement,
	 * if user is the first time unlock this achievement, add achievement to user and return flag variable with "new",
	 * which means make the program to do the following work related badge and campaign.
	 * @param username	user name
	 * @param achi_sn	achievement serial number
	 * @return 			string flag : new/old whether the first time unlock the achievement
	 */
	public String addAchiToUser(String username, String achi_sn);
	
	/**
	 * Add badge object to the user objcet's property badge Set.
	 * <p>it does not meant this user unlocked this badge,
	 * when user unlocked one achievement that related this badge 
	 * and in the same time this user have not unlocked any other achievements related this badge,
	 * system will call this function to create the relationship of this user and badge. 
	 * @param username 	user name
	 * @param badge_sn 	badge serial number
	 * @return			true/false whether successfully add badge to user
	 */
	public boolean addBadgeToUser(String username, String badge_sn);
	
	/**
	 * Increase the number of achievements of the specific badge, which achievement that user just unlocked.
	 * <p>in user_badge relationship table, two fields "badge_total" and "badge_num" that the first one stored the
	 * achievements number this badge has, and the second one is the quantity of achievements that this user unlocked.
	 * this function is invoked after user triggered one achievement first time and add the number plus one to the table's
	 * "badge_num" field and also has functionality to judge whether "badge_total" equals to "badge_num", if so, make the
	 * unlock_flag to 1, which means this user obtained the badge.
	 * @param username	user name
	 * @param badge_id	badge id
	 * @return			true/false
	 */
	public boolean addAchiUnlockedNumForUserBadge(String username, int badge_id);
	
	/**
	 * Increase the number of achievements of the specific campaign, which achievement that user just unlocked.
	 * <p>in user_campaign relationship table, two fields "camp_total" and "camp_num" that the first one stored the
	 * achievements number this campaign has, and the second one is the quantity of achievements that this user unlocked.
	 * this function is invoked after user triggered one achievement first time and add the number plus one to the table's
	 * "camp_num" field and also has functionality to judge whether "camp_total" equals to "camp_num", if so, make the
	 * unlock_flag to 1, which means this user could join in this campaign.
	 * @param username	user name
	 * @param camp_id	camp id
	 * @return			true/false
	 */
	public boolean addAchiUnlockedNumToUserCamp(String username, int camp_id);

	/**
	 * Get unique user object by user name.
	 * @param username	user name
	 * @return 			user object
	 */
	public User getUserByUsername(String username);
	
	/**
	 * Get user List by input string for fuzzy query.
	 * @param inputString	user name
	 * @return 				User List
	 */
	public List<User> getUserListByInputString(String inputString);
	
	/**
	 * Get all user objects with List format
	 * @return user List
	 */
	public List<User> getUserList();
	

	/**
	 * Add score to the user when user unlocked the achievement in the first time.
	 * @param username		user name
	 * @param achi_score	achievement's score points
	 * @return				true/false
	 */
	public boolean addScoreToUser(String username, long achi_score);
}
